#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/string.hpp"

class SubscriberNode : public rclcpp::Node
{
	//this subscribe the topic "command", print string message after each reception
  private:
	rclcpp::Subscription<std_msgs::msg::String>::SharedPtr subscriber;

  private:
	void subscription_callback(std_msgs::msg::String msg)
	{
		RCLCPP_INFO(this->get_logger(), "got message: \r\n%s\r\n", msg.data.c_str());
	}

  public:
	SubscriberNode(std::string name) : Node(name)
	{
		RCLCPP_INFO(this->get_logger(), "this is %s", name.c_str());
		subscriber = this->create_subscription<std_msgs::msg::String>(
			"command", 10, std::bind(&SubscriberNode::subscription_callback, this, std::placeholders::_1));

		return;
	}
};

int main(int argc, char **argv)
{
	rclcpp::init(argc, argv);
	auto node = std::make_shared<SubscriberNode>("command_subscriber");
	rclcpp::spin(node);
	rclcpp::shutdown();
	return 0;
}
